<!DOCTYPE html>
<html>
	<head>
	    <meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
		<link rel="stylesheet" href="$!rc.contextPath/common/bootstrap.min.css" />
		<link rel="stylesheet" href="$!rc.contextPath/common/common.css" />
		<link rel="stylesheet" href="//at.alicdn.com/t/font_604979_te3xq49ymnf2bj4i.css" />
		<link rel="stylesheet" href="$!rc.contextPath/common/swiper.min.css" />
		<link rel="stylesheet" href="$!rc.contextPath/css/shops_detail.css" />
		<title>$!sku.skuName</title>
	</head>
	<body style='padding-top: 0px; '>
	<div class="title text-center">
		<a id="back" onClick="javascript:window.history.go(-1)"><</a>
		商品详情
	</div>
	<div class="banner swiper-container">
		<div class="swiper-wrapper">
			#foreach($banner in $bannerList)
			<div class="swiper-slide">
				<img src="http://app.tmaipay.com/$!banner.attach_path" alt="" />
			</div>
			#end
		</div>
		<div class="discount">
			<div class="discount-left">
				<div class="old-price">
					<div class="yen">
						￥
					</div>
					<div class="price-num">
						$!limit.prePrice 
					</div>
					<div class="line"></div>
				</div>
			</div>
			<div class="discount-right" id="showTimes">
			</div>
		</div>
	</div>
	<div class="shops-infor">
		<div class="shops-title">
			$!sku.skuName
		</div>
		<div class="now-price">
			<div class="yen">
				￥
			</div>
			<div class="price-num">
				$!sku.promotionPrice &nbsp;&nbsp;
				#if ($!score > 0)
				<span style="font-size: 12px;">赠送$!score积分</span>
				#end
			</div>
		</div>
		<div class="advantage">
			#foreach($tag in $tagList)
			<div class="advantage-item">
				<i class="iconfont icon-gouhao"></i>
				<span>$!tag.sku_tag_name</span>
			</div>
			#end
			<div class="small-title spec-title">
				<span>规格</span>
				<i class="iconfont icon-arrow-right-copy-copy-copy"></i>
			</div>
			<ul class="spec-list clear">
				<li class="spec-item">已选：$!sku.skuFormat</li>
				<!-- <li class="spec-item">2斤</li>
				<li class="spec-item">3斤</li>
				<li class="spec-item">1斤</li> -->
			</ul>
			<div class="small-title count">
				<span>数量：</span>
				<div class="count-operate">
					<div class="minus">-</div>
					<div class="count-con" id="skuAmount">1</div>
					<div class="plus">+</div>
				</div>
			</div>
		</div>
	</div>
	<div class="shops-con">
		<div class="brief-title">
			<span>商品简介</span>
		</div>
		<div class="brief-img">
			<!-- <img src="../../../img/xiangqing.jpg" alt="" /> -->
			$!sku.skuNotes
		</div>
	</div>
	<div class="foot clear">
		<div class="foot-left">
			<div>
				<i class="iconfont icon-shouye"></i>
				<p>首页</p>
			</div>
			<div class="collect" onclick="f_collect()">
				<i class="iconfont #if($!isCollect) icon-caidan_wujiaoxingman active #else icon-caidan_wujiaoxingkong #end"></i>
				<p>收藏</p>
			</div>
		</div>
		<div class="foot-right">
			<a style="background: #3794e2ad;color:white;">已抢$!limit.limitNum份</a>
			#if($!limit.spellStatus == '0')
				<a href="javascript:void(0);" style="background-color: #777;">未开始</a>
			#elseif($!limit.spellStatus == '1')
				<a href="javascript:f_pay('$!sku.skuId');">立即抢购</a>
			#elseif($!limit.spellStatus == '2')
				<a href="javascript:f_pay('$!sku.skuId');">立即抢购</a>
			#elseif($!limit.spellStatus == '3')
				<a href="javascript:void(0);" style="background-color: #777;">已结束</a>
			#end
			
		</div>
	</div>
	</body>
	<script src="$!rc.contextPath/common/jquery-1.8.3.min.js"></script>
	<script src="$!rc.contextPath/common/swiper.min.js"></script>
	<script src="$!rc.contextPath/js/shops_detail.js"></script>
	
	<script type="text/javascript">
		/* if(window.location.href.indexOf("storeId") == -1){
			window.location.assign(window.location.href + '&storeId=' + sessionStorage.getItem('storeId'));
			$("#back").attr("onclick", "javascript:window.history.go(-2)");
		} */
		$(function(){
			var second = '$!secs'; // 剩余秒数
			// 写一个方法，将秒数专为天数
			function f_toDays(){
				
				var s = second % 60; // 秒
				var mi = (second - s) / 60 % 60; // 分钟
				var h =  ((second - s) / 60 - mi ) / 60 % 24; // 小时
				var d =  (((second - s) / 60 - mi ) / 60 - h ) / 24 // 天
				
				var html_str = f_PrefixInteger(d, 2) + '天' + f_PrefixInteger(h, 2) + '小时' + f_PrefixInteger(mi, 2) + '分钟' + f_PrefixInteger(s, 2) + '秒';
				
				return  html_str;
			}
			
			//定时器
			if(second){
				window.setInterval(function(){
					 second --;
					 $("#showTimes").html(f_toDays());
				}, 1000);
			}
			
		})
		
		function f_PrefixInteger(num, length) {
		 	return (Array(length).join('0') + num).slice(-length);
		}
		
		function f_collect(){
			var skuId = '$!sku.skuId';
			$.ajax({
                type: 'POST',
                url: '$!rc.contextPath/sku/collect',
                data : {
                	skuId : skuId
                },
                dataType: 'json',
                success: function(data){
                    console.log(data);
                    if(data.code != '0'){
                    	alert(data.text)
                    }
                }
            });
		}
		
		function f_pay(skuId){
			var skuAmount = $("#skuAmount").text();
			var price = '$!limit.prePrice';
			var limitTimeId = '$!limit.limitTimeId';
			var money = (price * skuAmount).toFixed(2);
			window.location.href = '$!rc.contextPath/pay?skuId=' + skuId + "&skuAmount=" + skuAmount + "&money=" + money + "&limitTimeId=" + limitTimeId;
		}
	</script>
</html>


